home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / 3rdParty / ARP.mod next >
Text File  |  1994-08-08  |  62KB  |  1,592 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: ARP.mod $
  4.   Description: Interface to arp.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 2.5 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 16:01:38 $
  10.  
  11.   Copyright © 1994, Frank Copeland.
  12.   This file is part of the Oberon-A Library.
  13.   See Oberon-A.doc for conditions of use and distribution.
  14.  
  15. ***************************************************************************)
  16.  
  17. MODULE ARP;
  18.  
  19. (*
  20. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  21. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  22. ** $V- OvflChk       $Z- ZeroVars
  23. *)
  24.  
  25. (*
  26.  ************************************************************************
  27.  *                                                                      *
  28.  * 5/3/89       ARPbase.h       by MKSoft from ARPbase.i by SDB         *
  29.  *                                                                      *
  30.  ************************************************************************
  31.  *                                                                      *
  32.  *      AmigaDOS Resource Project -- Library Include File               *
  33.  *                                   for Lattice C 5.x or Manx C 5.x    *
  34.  *                                                                      *
  35.  ************************************************************************
  36.  *                                                                      *
  37.  *      Copyright (c) 1987/1988/1989 by Scott Ballantyne                *
  38.  *                                                                      *
  39.  *      The arp.library, and related code and files may be freely used  *
  40.  *      by supporters of ARP.  Modules in the arp.library may not be    *
  41.  *      extracted for use in independent code, but you are welcome to   *
  42.  *      provide the arp.library with your work and call on it freely.   *
  43.  *                                                                      *
  44.  *      You are equally welcome to add new functions, improve the ones  *
  45.  *      within, or suggest additions.                                   *
  46.  *                                                                      *
  47.  *      BCPL programs are not welcome to call on the arp.library.       *
  48.  *      The welcome mat is out to all others.                           *
  49.  *                                                                      *
  50.  ************************************************************************
  51.  *                                                                      *
  52.  * N O T E !  You MUST! have IoErr() defined as LONG to use LastTracker *
  53.  *            If your compiler has other defines for this, you may wish *
  54.  *            to remove the prototype for IoErr() from this file.       *
  55.  *                                                                      *
  56.  ************************************************************************
  57.  *)
  58.  
  59. (*
  60.  ************************************************************************
  61.  *      First we need to include the Amiga Standard Include files...    *
  62.  ************************************************************************
  63.  *)
  64.  
  65.  
  66. IMPORT E := Exec, D := Dos, I := Intuition, SYS := SYSTEM;
  67.  
  68. (* All pointers are declared first for convenience *)
  69.  
  70. TYPE
  71.  
  72.   ArpBasePtr *             = CPOINTER TO ArpBase;
  73.   EnvBasePtr *             = CPOINTER TO EnvBase;
  74.   FileRequesterPtr *       = CPOINTER TO FileRequester;
  75.   AnchorPathPtr *          = CPOINTER TO AnchorPath;
  76.   AChainPtr *              = CPOINTER TO AChain;
  77.   DirectoryEntryPtr *      = CPOINTER TO DirectoryEntry;
  78.   TrackedResourcePtr *     = CPOINTER TO TrackedResource;
  79.   TrackerPtr *             = CPOINTER TO Tracker;
  80.   DefaultTrackerPtr *      = CPOINTER TO DefaultTracker;
  81.   GenericTrackerPtr *      = CPOINTER TO GenericTracker;
  82.   WindowTrackerPtr *       = CPOINTER TO WindowTracker;
  83.   ResListPtr *             = CPOINTER TO ResList;
  84.   ZombieMsgPtr *           = CPOINTER TO ZombieMsg;
  85.   ProcessControlBlockPtr * = CPOINTER TO ProcessControlBlock;
  86.   NewShellPtr *            = CPOINTER TO NewShell;
  87.   ResidentProgramNodePtr * = CPOINTER TO ResidentProgramNode;
  88.   ResidentProgramTagPtr *  = CPOINTER TO ResidentProgramTag;
  89.   ProcessMemoryPtr *       = CPOINTER TO ProcessMemory;
  90.   DateTimePtr *            = CPOINTER TO DateTime;
  91.  
  92.  
  93. CONST
  94.  
  95. (*
  96.  ************************************************************************
  97.  *      Standard definitions for arp library information                *
  98.  ************************************************************************
  99.  *)
  100.  
  101.   name *    = "arp.library";   (* Name of library... *)
  102.   version * = 39;              (* Current version... *)
  103.  
  104. TYPE
  105.  
  106. (*
  107.  ************************************************************************
  108.  *      The current ARP library node...                                 *
  109.  ************************************************************************
  110.  *)
  111.  
  112.   ArpBase * = RECORD (E.Library)
  113.   (*libNode *      : E.Library;     (* Standard library node               *)*)
  114.     dosRootNode *  : D.RootNodePtr; (* Copy of dlRoot                      *)
  115.     abFlags *      : E.BSET;        (* See bitdefs below                   *)
  116.     escChar *      : CHAR;          (* Character to be used for escaping   *)
  117.     arpReserved1 * : LONGINT;       (* ArpLib's use only!!                 *)
  118.     envBase *      : E.LibraryPtr;  (* Dummy library for MANX compatibility*)
  119.     dosBase *      : E.LibraryPtr;  (* Cached DosBase                      *)
  120.     gfxBase *      : E.LibraryPtr;  (* Cached GfxBase                      *)
  121.     intuiBase *    : E.LibraryPtr;  (* Cached IntuitionBase                *)
  122.     resLists *     : E.MinList;     (* Resource trackers                   *)
  123.     residentPrgList * : ResidentProgramNodePtr; (* Resident Programs.        *)
  124.     resPrgProtection * : E.SignalSemaphore; (* protection for above       *)
  125.     segList *      : D.BPTR;        (* Pointer to loaded libcode (a BPTR). *)
  126.   END; (* ArpBase *)
  127.  
  128. TYPE
  129.  
  130. (*
  131.  ************************************************************************
  132.  *      The following is here *ONLY* for information and for            *
  133.  *      compatibility with MANX.  DO NOT use in new code!               *
  134.  ************************************************************************
  135.  *)
  136.  
  137.   EnvBase * = RECORD (E.Library)
  138.   (*libNode *  : E.Library;  (* Standard library node for linkage    *)*)
  139.     envSpace * : E.APTR;     (* Access only when Forbidden!          *)
  140.     envSize *  : E.ULONG;    (* Total allocated mem for EnvSpace     *)
  141.     arpBase *  : ArpBasePtr; (* Added in V32 for Resource Tracking   *)
  142.   END; (* EnvBase *)
  143.  
  144.  
  145. CONST
  146.  
  147. (*
  148.  ************************************************************************
  149.  *      These are used in release 33.4 but not by the library code.     *
  150.  *      Instead, individual programs check for these flags.             *
  151.  ************************************************************************
  152.  *)
  153.  
  154.   wildWorld * = 0;              (* Mixed BCPL/Normal wildcards. *)
  155.   wildBCPL  * = 1;              (* Pure BCPL wildcards.         *)
  156.  
  157.  
  158. CONST
  159.  
  160. (*
  161.  ************************************************************************
  162.  * The alert object is what you use if you really must return an alert  *
  163.  * to the user. You would normally OR this with another alert number    *
  164.  * from the alerts.h file. Generally, should be NON deadend alerts.     *
  165.  *                                                                      *
  166.  * For example, if you can't open ArpLibrary:                           *
  167.  *      Alert( (AgOpenLib|AoArpLib), 0L);                               *
  168.  ************************************************************************
  169.  *)
  170.  
  171.   aoArpLib       * = 00008036H;             (* Alert object *)
  172.  
  173. CONST
  174.  
  175. (*
  176.  ************************************************************************
  177.  *      Alerts that arp.library may return...                           *
  178.  ************************************************************************
  179.  *)
  180.  
  181.   anArpLib       * = 03600000H;   (* Alert number                         *)
  182.   anArpNoMem     * = 03610000H;   (* No more memory                       *)
  183.   anArpInputMem  * = 03610002H;   (* No memory for input buffer           *)
  184.   anArpNoMakeEnv * = 83610003H;   (* No memory to make EnvLib             *)
  185.  
  186.   anArpNoDOS     * = 83630001H;   (* Can't open dos.library               *)
  187.   anArpNoGfx     * = 83630002H;   (* Can't open graphics.library          *)
  188.   anArpNoIntuit  * = 83630003H;   (* Can't open intuition                 *)
  189.   anBadPackBlues * = 83640000H;   (* Bad packet returned to SendPacket()  *)
  190.   anZombie       * = 83600003H;   (* Zombie roaming around system         *)
  191.  
  192.   anArpScattered * = 83600002H;   (* Scatter loading not allowed for arp  *)
  193.  
  194.  
  195. CONST
  196.  
  197. (*
  198.  ************************************************************************
  199.  *      Return codes you can get from calling ARP Assign()...           *
  200.  ************************************************************************
  201.  *)
  202.  
  203.   assignOK       * = 0; (* Everything is cool and groovey                *)
  204.   assignNODEV    * = 1; (* "Physical" is not valid for assignment        *)
  205.   assignFATAL    * = 2; (* Something really icky happened                *)
  206.   assignCANCEL   * = 3; (* Tried to cancel something but it won't cancel *)
  207.  
  208. CONST
  209.  
  210. (*
  211.  ************************************************************************
  212.  *      Size of buffer you need if you are going to call ReadLine()     *
  213.  ************************************************************************
  214.  *)
  215.  
  216.   maxInputBuf     * = 256;
  217.  
  218. TYPE
  219.  
  220. (*
  221.  ************************************************************************
  222.  *      The ARP file requester data structure...                        *
  223.  ************************************************************************
  224.  *)
  225.  
  226.  
  227.   FileRequester * = RECORD
  228.     hail *      : E.STRPTR;        (* Hailing text                 *)
  229.     file *      : E.STRPTR;        (* Filename array (FCHARS + 1)  *)
  230.     dir *       : E.STRPTR;        (* Directory array (DSIZE + 1)  *)
  231.     window *    : I.WindowPtr;     (* Window requesting or NULL    *)
  232.     funcFlags * : E.BSET;          (* Set bitdef's below           *)
  233.     flags2 *    : E.BSET;          (* New flags...                 *)
  234.     function *  : E.PROC;          (* Your function, see bitdef's  *)
  235.     leftEdge *  : INTEGER;         (* To be used later...          *)
  236.     topEdge *   : INTEGER;
  237.   END; (* FileRequester *)
  238.  
  239.  
  240. CONST
  241.  
  242. (*
  243.  ************************************************************************
  244.  * The following are the defines for frFuncFlags.  These bits tell      *
  245.  * FileRequest() what your frUserFunc is expecting, and what            *
  246.  * FileRequest() should call it for.                                    *
  247.  *                                                                      *
  248.  * You are called like so:                                              *
  249.  * frFunction(Mask, Object)                                             *
  250.  * E.ULONG        Mask;                                                 *
  251.  * E.APTR         *Object;                                              *
  252.  *                                                                      *
  253.  * The Mask is a copy of the flag value that caused FileRequest() to    *
  254.  * call your function. You can use this to determine what action you    *
  255.  * need to perform, and exactly what Object is, so you know what to do  *
  256.  * and what to return.                                                  *
  257.  ************************************************************************
  258.  *)
  259.  
  260.   frDoWildFunc  * = 7; (* Call me with a FIB and a name, ZERO return accepts.       *)
  261.   frDoMsgFunc   * = 6; (* You get all IDCMP messages not for FileRequest()          *)
  262.   frDoColor     * = 5; (* Set this bit for that new and different look              *)
  263.   frNewIDCMP    * = 4; (* Force a new IDCMP (only if frWindow != NULL)             *)
  264.   frNewWindFunc * = 3; (* You get to modify the newwindow structure.                *)
  265.   frAddGadFunc  * = 2; (* You get to add gadgets.                                   *)
  266.   frGEventFunc  * = 1; (* Function to call if one of your gadgets is selected.      *)
  267.   frListFunc    * = 0; (* Not implemented yet.                                      *)
  268.  
  269.  
  270. CONST
  271.  
  272. (*
  273.  ************************************************************************
  274.  * The FR2 bits are for frFlags2 in the file requester structure     *
  275.  ************************************************************************
  276.  *)
  277.  
  278.   fr2LongPath   * = 0; (* Specify the frDir buffer is 256 bytes long *)
  279.  
  280.  
  281. CONST
  282.  
  283. (*
  284.  ************************************************************************
  285.  *      The sizes of the different buffers...                           *
  286.  ************************************************************************
  287.  *)
  288.  
  289.   fChars * = 32;     (* Filename size                              *)
  290.   dSize *  = 33;     (* Directory name size if not FR2LongPath     *)
  291.  
  292.   longDSize * = 254;    (* If FR2LongPath is set, use longDSIZE    *)
  293.   longFSize * = 126;    (* For compatibility with ARPbase.i        *)
  294.  
  295.   frFirstGadget * = 7680H; (* User gadgetID's must be less than this value *)
  296.  
  297.  
  298. TYPE
  299.  
  300. (*
  301.  ************************************************************************
  302.  * Structure expected by FindFirst()/FindNext()                         *
  303.  *                                                                      *
  304.  * You need to allocate this structure and initialize it as follows:    *
  305.  *                                                                      *
  306.  * Set apBreakBits to the signal bits (CDEF) that you want to take a    *
  307.  * break on, or NULL, if you don't want to convenience the user.        *
  308.  *                                                                      *
  309.  * if you want to have the FULL PATH NAME of the files you found,       *
  310.  * allocate a buffer at the END of this structure, and put the size of  *
  311.  * it into apStrLen.  If you don't want the full path name, make sure   *
  312.  * you set apStrLen to zero.  In this case, the name of the file, and   *
  313.  * stats are available in the apInfo, as per usual.                     *
  314.  *                                                                      *
  315.  * Then call FindFirst() and then afterwards, FindNext() with this      *
  316.  * structure.  You should check the return value each time (see below)  *
  317.  * and take the appropriate action, ultimately calling                  *
  318.  * FreeAnchorChain() when there are no more files and you are done.     *
  319.  * You can tell when you are done by checking for the normal AmigaDOS   *
  320.  * return code errorNoMoreENTRIES.                                      *
  321.  *                                                                      *
  322.  * You will also have to check the DirEntryType variable in the apInfo  *
  323.  * structure to determine what exactly you have received.               *
  324.  ************************************************************************
  325.  *)
  326.  
  327.   AnchorPath * = RECORD
  328.     base *       : AChainPtr; (* Pointer to first anchor                *)
  329.     last *       : AChainPtr; (* Pointer to last anchor                 *)
  330.     breakBits *  : SET;       (* Bits to break on                       *)
  331.     foundBreak * : SET;       (* Bits we broke on. Also returns errorBREAK*)
  332.     flags *      : E.BSET;    (* New use for the extra word...          *)
  333.     reserved *   : SYS.BYTE;  (* To fill it out...                      *)
  334.     strLen *     : INTEGER;   (* This is what used to be apLength       *)
  335.     info *       : D.FileInfoBlock;
  336.   (*buf *        : ARRAY OF SYS.BYTE; (* Allocate a buffer here, if desired *)*)
  337.   END; (* AnchorPath *)
  338.  
  339. CONST
  340.  
  341. (*
  342.  ************************************************************************
  343.  *      Bit definitions for the new apFlags...                         *
  344.  ************************************************************************
  345.  *)
  346.  
  347.   apDoWild      * = 0;    (* User option ALL                              *)
  348.   apItsWild     * = 1;    (* Set by FindFirst, used by FindNext           *)
  349.   apDoDir       * = 2;    (* Bit is SET if a DIR node should be entered   *)
  350.                           (* Application can RESET this bit to AVOID      *)
  351.                           (* entering a dir.                              *)
  352.   apDidDir      * = 3;    (* Bit is set for an "expired" dir node         *)
  353.   apNoMemErr    * = 4;    (* Set if there was not enough memory           *)
  354.   apDoDot       * = 5;    (* If set, '.' (DOT) will convert to CurrentDir *)
  355.  
  356.  
  357. TYPE
  358.  
  359. (*
  360.  ************************************************************************
  361.  * Structure used by the pattern matching functions, no need to obtain, *
  362.  * diddle or allocate this yourself.                                    *
  363.  *                                                                      *
  364.  * Note:  If you did, you will now break as it has changed...           *
  365.  ************************************************************************
  366.  *)
  367.  
  368.   AChain = RECORD
  369.     child  : AChainPtr;
  370.     parent : AChainPtr;
  371.     lock   : D.FileLockPtr;
  372.     info   : D.FileInfoBlockPtr;
  373.     flags  : E.BSET;
  374.   (*string : ARRAY OF CHAR;   (* Just as is .i file   *)*)
  375.   END; (* AChain *)             (* ???  Don't use this! *)
  376.  
  377. CONST
  378.  
  379.   ddPatternBit  * = 0;
  380.   ddExaminedBit * = 1;
  381.   ddCompleted   * = 2;
  382.   ddAllBit      * = 3;
  383.  
  384.  
  385. CONST
  386.  
  387. (*
  388.  ************************************************************************
  389.  * Constants used by wildcard routines                                  *
  390.  *                                                                      *
  391.  * These are the pre-parsed tokens referred to by pattern match.  It    *
  392.  * is not necessary for you to do anything about these, FindFirst()     *
  393.  * FindNext() handle all these for you.                                 *
  394.  ************************************************************************
  395.  *)
  396.  
  397.   pAny           * = 80X;   (* Token for '*' | '#?' *)
  398.   pSingle        * = 81X;   (* Token for '?'        *)
  399.  
  400. CONST
  401.  
  402. (*
  403.  ************************************************************************
  404.  * No need to muck with these as they may change...                     *
  405.  ************************************************************************
  406.  *)
  407.  
  408.   pOrStart       * = 82X;   (* Token for '('        *)
  409.   pOrNext        * = 83X;   (* Token for '|'        *)
  410.   pOrEnd         * = 84X;   (* Token for ')'        *)
  411.   pNot           * = 85X;   (* Token for '~'        *)
  412.   pNotClass      * = 87X;   (* Token for '^'        *)
  413.   pClass         * = 88X;   (* Token for '[]'       *)
  414.   pRepBeg        * = 89X;   (* Token for '['        *)
  415.   pRepEnd        * = 8AX;   (* Token for ']'        *)
  416.  
  417.  
  418. TYPE
  419.  
  420. (*
  421.  ************************************************************************
  422.  * Structure used by AddDANode(), AddDADevs(), FreeDAList().            *
  423.  *                                                                      *
  424.  * This structure is used to create lists of names, which normally      *
  425.  * are devices, assigns, volumes, files, or directories.                *
  426.  ************************************************************************
  427.  *)
  428.  
  429.   DirectoryEntry * = RECORD
  430.     next *  : DirectoryEntryPtr; (* Next in list                      *)
  431.     type *  : SHORTINT;          (* dlxmumble                         *)
  432.     flags * : E.BSET;            (* For future expansion, DO NOT USE! *)
  433.   (*name *  : ARRAY OF CHAR;     (* The name of the thing found       *)*)
  434.   END; (* DirectoryEntry *)
  435.  
  436. CONST
  437.  
  438. (*
  439.  ************************************************************************
  440.  * Defines you use to get a list of the devices you want to look at.    *
  441.  * For example, to get a list of all directories and volumes, do:       *
  442.  *                                                                      *
  443.  *      AddDADevs( mydalist, (DlfDIRS | dlfVOLUMES) )                   *
  444.  *                                                                      *
  445.  * After this, you can examine the detype field of the elements added   *
  446.  * to your list (if any) to discover specifics about the objects added. *
  447.  *                                                                      *
  448.  * Note that if you want only devices which are also disks, you must    *
  449.  * (DlfDEVICES | dlfDISKONLY).                                          *
  450.  ************************************************************************
  451.  *)
  452.  
  453.   dlDevices     * = 0;      (* Return devices                               *)
  454.   dlDiskOnly    * = 1;      (* Modifier for above: Return disk devices only *)
  455.   dlVolumes     * = 2;      (* Return volumes only                          *)
  456.   dlDirs        * = 3;      (* Return assigned devices only                 *)
  457.  
  458.  
  459. CONST
  460.  
  461. (*
  462.  ************************************************************************
  463.  * Legal deType values, check for these after a call to AddDADevs(),    *
  464.  * or use on your own as the ID values in AddDANode().                  *
  465.  ************************************************************************
  466.  *)
  467.  
  468.   dlxFile        * = 0;      (* AddDADevs() can't determine this     *)
  469.   dlxDir         * = 8;      (* AddDADevs() can't determine this     *)
  470.   dlxDevice      * = 16;     (* It's a resident device               *)
  471.   dlxVolume      * = 24;     (* Device is a volume                   *)
  472.   dlxUnmounted   * = 32;     (* Device is not resident               *)
  473.   dlxAssign      * = 40;     (* Device is a logical assignment       *)
  474.  
  475. (*
  476.  ************************************************************************
  477.  *      Resource Tracking stuff...                                      *
  478.  ************************************************************************
  479.  *                                                                      *
  480.  * There are a few things in arp.library that are only directly         *
  481.  * acessable from assembler.  The glue routines provided by us for      *
  482.  * all 'C' compilers use the following conventions to make these        *
  483.  * available to C programs.  The glue for other language's should use   *
  484.  * as similar a mechanism as possible, so that no matter what language  *
  485.  * or compiler we speak, when talk about arp, we will know what the     *
  486.  * other guy is saying.                                                 *
  487.  *                                                                      *
  488.  * Here are the cases:                                                  *
  489.  *                                                                      *
  490.  * Tracker calls...                                                     *
  491.  *              These calls return the Tracker pointer as a secondary   *
  492.  *              result in the register A1.  For C, there is no clean    *
  493.  *              way to return more than one result so the tracker       *
  494.  *              pointer is returned in IoErr().  For ease of use,       *
  495.  *              there is a define that typecasts IoErr() to the correct *
  496.  *              pointer type.  This is called LastTracker and should    *
  497.  *              be source compatible with the earlier method of storing *
  498.  *              the secondary result.                                   *
  499.  *                                                                      *
  500.  * GetTracker() -                                                       *
  501.  *              Syntax is a bit different for C than the assembly call  *
  502.  *              The C syntax is GetTracker(ID).  The binding routines   *
  503.  *              will store the ID into the tracker on return.  Also,    *
  504.  *              in an effort to remain consistant, the tracker will     *
  505.  *              also be stored in LastTracker.                          *
  506.  *                                                                      *
  507.  * In cases where you have allocated a tracker before you have obtained *
  508.  * a resource (usually the most efficient method), and the resource has *
  509.  * not been obtained, you will need to clear the tracker id.  The macro *
  510.  * clearID() has been provided for that purpose.  It expects a pointer *
  511.  * to a DefaultTracker sort of struct.                                  *
  512.  ************************************************************************
  513.  
  514. #define CLEAR_ID(t)     ((SHORT * ) t)[-1]* =NULL
  515.  
  516.  ************************************************************************
  517.  * You MUST prototype IoErr() to prevent the possible error in defining *
  518.  * IoErr() and thus causing LastTracker to give you trash...            *
  519.  *                                                                      *
  520.  * N O T E !  You MUST! have IoErr() defined as LONG to use LastTracker *
  521.  *            If your compiler has other defines for this, you may wish *
  522.  *            to remove the prototype for IoErr().                      *
  523.  ************************************************************************
  524.  
  525. #define LastTracker     ((struct DefaultTracker * )IoErr())
  526. *)
  527.  
  528. TYPE
  529.  
  530. (*
  531.  ************************************************************************
  532.  * The rlFirstItem list (ResList) is a list of TrackedResource (below)  *
  533.  * It is very important that nothing in this list depend on the task    *
  534.  * existing at resource freeing time (i.e., RemTask(0L) type stuff,     *
  535.  * DeletePort() and the rest).                                          *
  536.  *                                                                      *
  537.  * The tracking functions return a struct Tracker *Tracker to you, this *
  538.  * is a pointer to whatever follows the trID variable.                  *
  539.  * The default case is reflected below, and you get it if you call      *
  540.  * GetTracker() ( see DefaultTracker below).                            *
  541.  *                                                                      *
  542.  * NOTE: The two user variables mentioned in an earlier version don't   *
  543.  * exist, and never did. Sorry about that (SDB).                        *
  544.  *                                                                      *
  545.  * However, you can still use ArpAlloc() to allocate your own tracking  *
  546.  * nodes and they can be any size or shape you like, as long as the     *
  547.  * base structure is preserved. They will be freed automagically just   *
  548.  * like the default trackers.                                           *
  549.  ************************************************************************
  550.  *)
  551.  
  552.   TrackedResource * = RECORD (E.MinNode)
  553.   (*node *   : E.MinNode;      (* Double linked pointer                *)*)
  554.     flags    : E.BSET;         (* Don't touch                          *)
  555.     lock     : SHORTINT;       (* Don't touch, for Get/FreeAccess()    *)
  556.     id *     : INTEGER;        (* Item's ID                            *)
  557. (*
  558.  ************************************************************************
  559.  * The struct DefaultTracker *Tracker portion of the structure.         *
  560.  * The stuff below this point can conceivably vary, depending           *
  561.  * on user needs, etc.  This reflects the default.                      *
  562.  ************************************************************************
  563.  *)
  564.     object * : E.APTR;
  565.     extra *  : E.APTR;
  566.   END; (* TrackedResource *)
  567.  
  568.  
  569. TYPE
  570.  
  571. (*
  572.  ************************************************************************
  573.  * You get a pointer to a struct of the following type when you call    *
  574.  * GetTracker().  You can change this, and use ArpAlloc() instead of    *
  575.  * GetTracker() to do tracking. Of course, you have to take a wee bit   *
  576.  * more responsibility if you do, as well as if you use trakGeneric     *
  577.  * stuff.                                                               *
  578.  *                                                                      *
  579.  * trakGeneric folks need to set up a task function to be called when   *
  580.  * an item is freed.  Some care is required to set this up properly.    *
  581.  *                                                                      *
  582.  * Some special cases are indicated by the unions below, for            *
  583.  * trakWindow, if you have more than one window opened, and don't       *
  584.  * want the IDCMP closed particularly, you need to set a ptr to the     *
  585.  * other window in dtWindow2.  See CloseWindowSafely() for more info.   *
  586.  * If only one window, set this to NULL.                                *
  587.  ************************************************************************
  588.  *)
  589.  
  590.   Tracker = RECORD END;
  591.  
  592.   DefaultTracker * = RECORD (Tracker)
  593.     object * : E.APTR;
  594.     extra *  : E.APTR;
  595.   END; (* DefaultTracker *)
  596.  
  597.   GenericTracker = RECORD (Tracker) (* The object being tracked      *)
  598.     dtResource * : E.APTR;          (* Whatever                      *)
  599.     tgVerify *   : LONGINT;         (* For use during trakGeneric    *)
  600.   END; (* GenericTracker *)
  601.  
  602.   WindowTracker = RECORD (Tracker)
  603.     tgFunction * : E.PROC;      (* Function to call for trakGeneric  *)
  604.     dtWindow2 *  : I.WindowPtr; (* For trakWindow                    *)
  605.   END; (* WindowTracker *)
  606.  
  607.  
  608. CONST
  609.  
  610. (*
  611.  ************************************************************************
  612.  *      Items the tracker knows what to do about                        *
  613.  ************************************************************************
  614.  *)
  615.  
  616.   trakAaMem      * = 0;      (* Default (ArpAlloc) element           *)
  617.   trakLock       * = 1;      (* File lock                            *)
  618.   trakTrFile     * = 2;      (* Opened file                          *)
  619.   trakWindow     * = 3;      (* Window -- see docs                   *)
  620.   trakScreen     * = 4;      (* Screen                               *)
  621.   trakLibrary    * = 5;      (* Opened library                       *)
  622.   trakDaMem      * = 6;      (* Pointer to DosAllocMem block         *)
  623.   trakMemNode    * = 7;      (* AllocEntry() node                    *)
  624.   trakSegList    * = 8;      (* Program segment                      *)
  625.   trakResList    * = 9;      (* ARP (nested) ResList                 *)
  626.   trakMem        * = 10;     (* Memory ptr/length                    *)
  627.   trakGeneric    * = 11;     (* Generic Element, your choice         *)
  628.   trakDaList     * = 12;     (* DAlist ( aka file request )          *)
  629.   trakAnchor     * = 13;     (* Anchor chain (pattern matching)      *)
  630.   trakFReq       * = 14;     (* FileRequest struct                   *)
  631.   trakFont       * = 15;     (* GfxBase CloseFont()                  *)
  632.   trakMax        * = 15;     (* Poof, anything higher is tossed      *)
  633.  
  634.   trUnlink      * = 7;      (* Free node bit                        *)
  635.   trReloc       * = 6;      (* This may be relocated (not used yet) *)
  636.   trMoved       * = 5;      (* Item moved                           *)
  637.  
  638.  
  639. TYPE
  640.  
  641. (*
  642.  ************************************************************************
  643.  * Note: ResList MUST be a DosAllocMem'ed list!, this is done for       *
  644.  * you when you call CreateTaskResList(), typically, you won't need     *
  645.  * to access/allocate this structure.                                   *
  646.  ************************************************************************
  647.  *)
  648.  
  649.   ResList * = RECORD (E.MinNode)
  650.   (*node *      : E.MinNode;  (* Used by arplib to link reslists      *)*)
  651.     taskID *    : E.TaskPtr;  (* Owner of this list                   *)
  652.     firstItem * : E.MinList;  (* List of Tracked Resources            *)
  653.     link *      : ResListPtr; (* SyncRun's use - hide list here       *)
  654.   END; (* ResList *)
  655.  
  656. CONST
  657.  
  658. (*
  659.  ************************************************************************
  660.  *      Returns from CompareLock()                                      *
  661.  ************************************************************************
  662.  *)
  663.  
  664.   lckEqual       * = 0;   (* The two locks refer to the same object       *)
  665.   lckVolume      * = 1;   (* Locks are on the same volume                 *)
  666.   lckDifVol1     * = 2;   (* Locks are on different volumes               *)
  667.   lckDifVol2     * = 3;   (* Locks are on different volumes               *)
  668.  
  669. TYPE
  670.  
  671. (*
  672.  ************************************************************************
  673.  *      ASyncRun() stuff...                                             *
  674.  ************************************************************************
  675.  * Message sent back on your request by an exiting process.             *
  676.  * You request this by putting the address of your message in           *
  677.  * pcbLastGasp, and initializing the ReplyPort variable of your         *
  678.  * ZombieMsg to the port you wish the message posted to.                *
  679.  ************************************************************************
  680.  *)
  681.  
  682.   ZombieMsg * = RECORD (E.Message)
  683.   (*execMessage * : E.Message;*)
  684.     taskNum *     : E.ULONG; (* Task ID                      *)
  685.     returnCode *  : LONGINT; (* Process's return code        *)
  686.     result2 *     : E.ULONG; (* System return code           *)
  687.     exitTime *    : D.Date;  (* Date stamp at time of exit   *)
  688.     userInfo *    : E.ULONG; (* For whatever you wish        *)
  689.   END; (* ZombieMsg *)
  690.  
  691. TYPE
  692.  
  693. (*
  694.  ************************************************************************
  695.  * Structure required by ASyncRun() -- see docs for more info.          *
  696.  ************************************************************************
  697.  *)
  698.  
  699.   ProcessControlBlock * = RECORD
  700.     stackSize * : E.ULONG;      (* Stacksize for new process                    *)
  701.     pri *       : SHORTINT;     (* Priority of new task                         *)
  702.     control *   : E.BSET;       (* Control bits, see defines below              *)
  703.     trapCode *  : E.APTR;       (* Optional Trap Code                           *)
  704.     input *     : D.BPTR;
  705.     output *    : D.BPTR;       (* Optional stdin, stdout                       *)
  706.     console *   : LONGINT;
  707.     (* console is a union of:
  708.       splatFile * : D.BPTR;     (* File to use for Open("*")                    *)
  709.       conName *   : E.STRPTR;   (* CON: filename                                *)
  710.     *)
  711.     loadedCode * : E.APTR;      (* If not null, will not load/unload code       *)
  712.     lastGasp *  : ZombieMsgPtr; (* ReplyMsg() to be filled in by exit           *)
  713.     wbProcess * : E.MsgPortPtr; (* Valid only when prNOCLI                    *)
  714.   END; (* ProcessControlBlock *)
  715.  
  716. CONST
  717.  
  718. (*
  719.  ************************************************************************
  720.  * Formerly needed to pass NULLCMD to a child.  No longer needed.       *
  721.  * It is being kept here for compatibility only...                      *
  722.  ************************************************************************
  723.  *)
  724.  
  725.   NoCmd   * = "\n";
  726.  
  727. CONST
  728.  
  729. (*
  730.  ************************************************************************
  731.  * The following control bits determine what ASyncRun() does on         *
  732.  * Abnormal Exits and on background process termination.                *
  733.  ************************************************************************
  734.  *)
  735.  
  736.   prSaveIO      * = 0;    (* Don't free/check file handles on exit        *)
  737.   prCloseSplat  * = 1;    (* Close Splat file, must request explicitly    *)
  738.   prNoCLI       * = 2;    (* Don't create a CLI process                   *)
  739. (*prInteractive * = 3;       This is now obsolete...                      *)
  740.   prCode        * = 4;    (* Dangerous yet enticing                       *)
  741.   prStdIO       * = 5;    (* Do the stdio thing, splat * = CON:Filename   *)
  742.  
  743.  
  744. CONST
  745.  
  746. (*
  747.  ************************************************************************
  748.  *      Error returns from SyncRun() and ASyncRun()                     *
  749.  ************************************************************************
  750.  *)
  751.  
  752.   prNoFile   * = -1;     (* Could not LoadSeg() the file                 *)
  753.   prNoMem    * = -2;     (* No memory for something                      *)
  754. (*prNoCLI      = -3;       This is now obsolete                          *)
  755.   prNoSlot   * = -4;     (* No room in TaskArray                         *)
  756.   prNoInput  * = -5;     (* Could not open input file                    *)
  757.   prNoOutput * = -6;     (* Could not get output file                    *)
  758. (*prNoLock     = -7;        This is now obsolete                         *)
  759. (*prArgErr     = -8;        This is now obsolete                         *)
  760. (*prNoBCPL     = -9;        This is now obsolete                         *)
  761. (*prBadLib     = -10;       This is now obsolete                         *)
  762.   prNoStdIO  * = -11;    (* Couldn't get stdio handles                   *)
  763.  
  764. CONST
  765.  
  766. (*
  767.  ************************************************************************
  768.  *      Added V35 of arp.library                                        *
  769.  ************************************************************************
  770.  *)
  771.  
  772.   prWantsMessage * = -12; (* Child wants you to report IoErr() to user    *)
  773.                           (* for SyncRun() only...                        *)
  774.   prNoShellProc  * = -13; (* Can't create a shell/cli process             *)
  775.   prNoExec       * = -14; (* 'E' bit is clear                             *)
  776.   prScript       * = -15; (* S and E are set, IoErr() contains directory  *)
  777.  
  778. TYPE
  779.  
  780. (*
  781.  ************************************************************************
  782.  * Version 35 ASyncRun() allows you to create an independent            *
  783.  * interactive or background Shell/CLI. You need this variant of the    *
  784.  * pcb structure to do it, and you also have new values for nshControl, *
  785.  * see below.                                                           *
  786.  *                                                                      *
  787.  * Syntax for Interactive shell is:                                     *
  788.  *                                                                      *
  789.  * rc=ASyncRun("Optional Window Name","Optional From File",&NewShell);  *
  790.  *                                                                      *
  791.  * Syntax for a background shell is:                                    *
  792.  *                                                                      *
  793.  * rc=ASyncRun("Command line",0L,&NewShell);                            *
  794.  *                                                                      *
  795.  * Same syntax for an Execute style call, but you have to be on drugs   *
  796.  * if you want to do that.                                              *
  797.  ************************************************************************
  798.  *)
  799.  
  800.   NewShell * = RECORD
  801.     stackSize * : E.ULONG;  (* stacksize shell will use for children        *)
  802.     pri *       : SHORTINT; (* ignored by interactive shells                *)
  803.     control *   : E.BSET;   (* bits/values: see above                       *)
  804.     logMsg *    : E.APTR;   (* Optional login message, if null, use default *)
  805.     input *     : D.BPTR;   (* ignored by interactive shells, but           *)
  806.     output *    : D.BPTR;   (* used by background and execute options.      *)
  807.     reserved *  : ARRAY 5 OF LONGINT;
  808.   END; (* NewShell *)
  809.  
  810. CONST
  811.  
  812. (*
  813.  ************************************************************************
  814.  * Bit Values for nshControl, you should use them as shown below, or    *
  815.  * just use the actual values indicated.                                *
  816.  ************************************************************************
  817.  *)
  818.  
  819.   prCli         * = 0;      (* Do a CLI, not a shell        *)
  820.   prBackGround  * = 1;      (* Background shell             *)
  821.   prExecute     * = 2;      (* Do as EXECUTE...             *)
  822.   prInteractive * = 3;      (* Run an interactive shell     *)
  823.   prFb          * = 7;      (* Alt function bit...          *)
  824.  
  825.  
  826. CONST
  827.  
  828. (*
  829.  ************************************************************************
  830.  *      Common values for shControl which allow you to do usefull      *
  831.  *      and somewhat "standard" things...                               *
  832.  ************************************************************************
  833.  *)
  834.  
  835.   interactiveShell * = { prFb, prInteractive };           (* Gimme a newshell!            *)
  836.   interactiveCLI   * = { prFb, prInteractive, prCli };    (* Gimme that ol newcli!        *)
  837.   backgroundShell  * = { prFb, prBackGround };            (* gimme a background shell     *)
  838.   executeMe        * = { prFb, prBackGround, prExecute }; (* aptly named, doncha think?   *)
  839.  
  840. CONST
  841.  
  842. (*
  843.  ************************************************************************
  844.  *      Additional IoErr() returns added by ARP...                      *
  845.  ************************************************************************
  846.  *)
  847.  
  848.   errorBufferOverflow   * = 303;    (* User or internal buffer overflow     *)
  849.   errorBreak            * = 304;    (* A break character was received       *)
  850.   errorNotExecutable    * = 305;    (* A file has E bit cleared             *)
  851.   errorNotCLI           * = 400;    (* Program/function neeeds to be cli    *)
  852.  
  853. TYPE
  854.  
  855. (*
  856.  ************************************************************************
  857.  *      Resident Program Support                                        *
  858.  ************************************************************************
  859.  * This is the kind of node allocated for you when you AddResidentPrg() *
  860.  * a code segment.  They are stored as a single linked list with the    *
  861.  * root in ArpBase.  If you absolutely *must* wander through this list  *
  862.  * instead of using the supplied functions, then you must first obtain  *
  863.  * the semaphore which protects this list, and then release it          *
  864.  * afterwards.  Do not use Forbid() and Permit() to gain exclusive      *
  865.  * access!  Note that the supplied functions handle this locking        *
  866.  * protocol for you.                                                    *
  867.  ************************************************************************
  868.  *)
  869.  
  870.   ResidentProgramNode * = RECORD
  871.     next *      : ResidentProgramNodePtr; (* next or NULL        *)
  872.     usage *     : LONGINT;       (* Number of current users      *)
  873.     accessCnt * : E.UWORD;       (* Total times used...          *)
  874.     checkSum *  : E.ULONG;       (* Checksum of code             *)
  875.     segment *   : D.BPTR;        (* Actual segment               *)
  876.     flags *     : E.WSET;        (* See definitions below...     *)
  877.   (*name *      : ARRAY OF CHAR; (* Allocated as needed          *)*)
  878.   END; (* ResidentProgramNode *)
  879.  
  880. CONST
  881.  
  882. (*
  883.  ************************************************************************
  884.  *      Bit definitions for rpnFlags....                                *
  885.  ************************************************************************
  886.  *)
  887.  
  888.   rpnNoCheck * = 0;      (* Set in rpnFlags for no checksumming...      *)
  889.   rpnCache *   = 1;      (* Private usage in v1.3...                    *)
  890.  
  891.  
  892. TYPE
  893.  
  894. (*
  895.  ************************************************************************
  896.  * If your program starts with this structure, ASyncRun() and SyncRun() *
  897.  * will override a users stack request with the value in rptStackSize.  *
  898.  * Furthermore, if you are actually attached to the resident list, a    *
  899.  * memory block of size rptDataSize will be allocated for you, and      *
  900.  * a pointer to this data passed to you in register A4.  You may use    *
  901.  * this block to clone the data segment of programs, thus resulting in  *
  902.  * one copy of text, but multiple copies of data/bss for each process   *
  903.  * invocation.  If you are resident, your program will start at         *
  904.  * rptInstruction, otherwise, it will be launched from the initial      *
  905.  * branch.                                                              *
  906.  ************************************************************************
  907.  *)
  908.  
  909.   ResidentProgramTag * = RECORD
  910.     nextSeg *   : D.BPTR;    (* Provided by DOS at LoadSeg time      *)
  911. (*
  912.  ************************************************************************
  913.  * The initial branch destination and rptInstruction do not have to be *
  914.  * the same.  This allows different actions to be taken if you are      *
  915.  * diskloaded or resident.  DataSize memory will be allocated only if   *
  916.  * you are resident, but StackSize will override all user stack         *
  917.  * requests.                                                            *
  918.  ************************************************************************
  919.  *)
  920.     bra *       : E.UWORD; (* Short branch to executable           *)
  921.     magic *     : E.UWORD; (* Resident majik value                 *)
  922.     stackSize * : E.ULONG; (* min stack for this process           *)
  923.     dataSize *  : E.ULONG; (* Data size to allocate if resident    *)
  924.     (*      instruction;        Start here if resident          *)
  925.   END; (* ResidentProgramTag *)
  926.  
  927. TYPE
  928.  
  929. (*
  930.  ************************************************************************
  931.  * The form of the ARP allocated node in your tasks memlist when        *
  932.  * launched as a resident program. Note that the data portion of the    *
  933.  * node will only exist if you have specified a nonzero value for       *
  934.  * rptDataSize. Note also that this structure is READ ONLY, modify     *
  935.  * values in this at your own risk.  The stack stuff is for tracking,   *
  936.  * if you need actual addresses or stack size, check the normal places  *
  937.  * for it in your process/task struct.                                  *
  938.  ************************************************************************
  939.  *)
  940.  
  941.   ProcessMemory * = RECORD (E.Node)
  942.   (*node *      : E.Node;*)
  943.     num *       : E.UWORD; (* This is 1 if no data, two if data    *)
  944.     stack *     : E.APTR;
  945.     stackSize * : E.ULONG;
  946.     data *      : E.APTR;  (* Only here if pmNum == 2              *)
  947.     dataSize *  : E.ULONG;
  948.   END; (* ProcessMemory *)
  949.  
  950. CONST
  951.  
  952. (*
  953.  ************************************************************************
  954.  * To find the above on your memlist, search for the following name.    *
  955.  * We guarantee this will be the only arp.library allocated node on     *
  956.  * your memlist with this name.                                         *
  957.  * i.e. FindName(task->tcbMemEntry, pmemNAME);                        *
  958.  ************************************************************************
  959.  *)
  960.  
  961.   pMemName       * = "ARP_MEM";
  962.  
  963.   residentMagic  * = 4AFCH;          (* same as rtcMATCHWORD (trapf) *)
  964.  
  965. TYPE
  966.  
  967. (*
  968.  ************************************************************************
  969.  *      Date String/Data structures                                     *
  970.  ************************************************************************
  971.  *)
  972.  
  973.   DateTime * = RECORD
  974.     stamp *   : D.Date;    (* DOS Datestamp                        *)
  975.     format *  : E.UBYTE;   (* controls appearance ot datStrDate    *)
  976.     flags *   : E.BSET;    (* See BITDEF's below                   *)
  977.     strDay *  : E.STRPTR;  (* day of the week string               *)
  978.     strDate * : E.STRPTR;  (* date string                          *)
  979.     strTime * : E.STRPTR;  (* time string                          *)
  980.   END; (* DateTime *)
  981.  
  982. CONST
  983.  
  984. (*
  985.  ************************************************************************
  986.  *      Size of buffer you need for each DateTime strings:              *
  987.  ************************************************************************
  988.  *)
  989.  
  990.   lenDatString   * = 10;
  991.  
  992. CONST
  993.  
  994. (*
  995.  ************************************************************************
  996.  *      For datFlags                                                   *
  997.  ************************************************************************
  998.  *)
  999.  
  1000.   dtSubst  * = 0; (* Substitute "Today" "Tomorrow" where appropriate      *)
  1001.   dtFuture * = 1; (* Day of the week is in future                         *)
  1002.  
  1003.  
  1004. CONST
  1005.  
  1006. (*
  1007.  ************************************************************************
  1008.  *      For datFormat                                                  *
  1009.  ************************************************************************
  1010.  *)
  1011.  
  1012.   formatDos * = 0;         (* dd-mmm-yy AmigaDOS's own, unique style               *)
  1013.   formatInt * = 1;         (* yy-mm-dd International format                        *)
  1014.   formatUSA * = 2;         (* mm-dd-yy The good'ol'USA.                            *)
  1015.   formatCDN * = 3;         (* dd-mm-yy Our brothers and sisters to the north       *)
  1016.   formatMAX * = formatCDN; (* Larger than this? Defaults to AmigaDOS               *)
  1017.  
  1018.  
  1019. (* --- Library Base variable -------------------------------------------- *)
  1020.  
  1021.  
  1022. VAR
  1023.  
  1024.   base *  : ArpBasePtr;
  1025.  
  1026.  
  1027. (* --- Library Functions ------------------------------------------------ *)
  1028.  
  1029. TYPE
  1030.  
  1031.   ArgArrayPtr = POINTER TO ArgArray;
  1032.   ArgArray = ARRAY 7 OF LONGINT;
  1033.  
  1034.  
  1035. (*
  1036.  ************************************************************************
  1037.  *  These duplicate the calls in dos.library                            *
  1038.  *  Only include if you can use arp.library without dos.library         *
  1039.  ************************************************************************
  1040.  *)
  1041.  
  1042.  
  1043. LIBCALL (base : ArpBasePtr) Open*
  1044.   ( name       [1] : ARRAY OF CHAR;
  1045.     accessMode [2] : LONGINT)
  1046.   : D.FileHandlePtr;
  1047.   -30;
  1048. LIBCALL (base : ArpBasePtr) Close*
  1049.   ( file [1] : D.FileHandlePtr );
  1050.   -36;
  1051. LIBCALL (base : ArpBasePtr) Read*
  1052.   ( file       [1] : D.FileHandlePtr;
  1053.     VAR buffer [2] : ARRAY OF SYS.BYTE;
  1054.     length     [3] : LONGINT)
  1055.   : LONGINT;
  1056.   -42;
  1057. LIBCALL (base : ArpBasePtr) Write*
  1058.   ( file   [1] : D.FileHandlePtr;
  1059.     buffer [2] : ARRAY OF SYS.BYTE;
  1060.     length [3] : LONGINT)
  1061.   : LONGINT;
  1062.   -48;
  1063. LIBCALL (base : ArpBasePtr) Input* ()
  1064.   : D.FileHandlePtr;
  1065.   -54;
  1066. LIBCALL (base : ArpBasePtr) Output* ()
  1067.   : D.FileHandlePtr;
  1068.   -60;
  1069. LIBCALL (base : ArpBasePtr) Seek*
  1070.   ( file     [1] : D.FileHandlePtr;
  1071.     position [2] : LONGINT;
  1072.     offset   [3] : LONGINT)
  1073.   : LONGINT;
  1074.   -66;
  1075. LIBCALL (base : ArpBasePtr) DeleteFile*
  1076.   ( name [1] : ARRAY OF CHAR )
  1077.   : BOOLEAN;
  1078.   -72;
  1079. LIBCALL (base : ArpBasePtr) Rename*
  1080.   ( oldName [1] : ARRAY OF CHAR;
  1081.     newName [2] : ARRAY OF CHAR )
  1082.   : BOOLEAN;
  1083.   -78;
  1084. LIBCALL (base : ArpBasePtr) Lock*
  1085.   ( name [1] : ARRAY OF CHAR;
  1086.     type [2] : LONGINT)
  1087.   : D.FileLockPtr;
  1088.   -84;
  1089. LIBCALL (base : ArpBasePtr) UnLock*
  1090.   ( lock [1] : D.FileLockPtr );
  1091.   -90;
  1092. LIBCALL (base : ArpBasePtr) DupLock*
  1093.   ( lock [1] : D.FileLockPtr )
  1094.   : D.FileLockPtr;
  1095.   -96;
  1096. LIBCALL (base : ArpBasePtr) Examine*
  1097.   ( lock          [1] : D.FileLockPtr;
  1098.     fileInfoBlock [2] : D.FileInfoBlockPtr )
  1099.   : BOOLEAN;
  1100.   -102;
  1101. LIBCALL (base : ArpBasePtr) ExNext*
  1102.   ( lock          [1] : D.FileLockPtr;
  1103.     fileInfoBlock [2] : D.FileInfoBlockPtr )
  1104.   : BOOLEAN;
  1105.   -108;
  1106. LIBCALL (base : ArpBasePtr) Info*
  1107.   ( lock           [1] : D.FileLockPtr;
  1108.     parameterBlock [2] : D.InfoDataPtr )
  1109.   : BOOLEAN;
  1110.   -114;
  1111. LIBCALL (base : ArpBasePtr) CreateDir*
  1112.   ( name [1] : ARRAY OF CHAR )
  1113.   : D.FileLockPtr;
  1114.   -120;
  1115. LIBCALL (base : ArpBasePtr) CurrentDir*
  1116.   ( lock [1] : D.FileLockPtr )
  1117.   : D.FileLockPtr;
  1118.   -126;
  1119. LIBCALL (base : ArpBasePtr) IoErr* ()
  1120.   : LONGINT;
  1121.   -132;
  1122. LIBCALL (base : ArpBasePtr) CreateProc*
  1123.   ( name      [1] : ARRAY OF CHAR;
  1124.     pri       [2] : LONGINT;
  1125.     segList   [3] : D.BPTR;
  1126.     stackSize [4] : LONGINT)
  1127.   : E.MsgPortPtr;
  1128.   -138;
  1129. LIBCALL (base : ArpBasePtr) Exit*
  1130.   ( returnCode [1] : LONGINT);
  1131.   -144;
  1132. LIBCALL (base : ArpBasePtr) LoadSeg*
  1133.   ( name [1] : ARRAY OF CHAR )
  1134.   : D.BPTR;
  1135.   -150;
  1136. LIBCALL (base : ArpBasePtr) UnLoadSeg*
  1137.   ( seglist [1] : D.BPTR );
  1138.   -156;
  1139. LIBCALL (base : ArpBasePtr) DeviceProc*
  1140.   ( name [1] : ARRAY OF CHAR )
  1141.   : E.MsgPortPtr;
  1142.   -174;
  1143. LIBCALL (base : ArpBasePtr) SetComment*
  1144.   ( name    [1] : ARRAY OF CHAR;
  1145.     comment [2] : ARRAY OF CHAR )
  1146.   : BOOLEAN;
  1147.   -180;
  1148. LIBCALL (base : ArpBasePtr) SetProtection*
  1149.   ( name    [1] : ARRAY OF CHAR;
  1150.     protect [2] : SET)
  1151.   : BOOLEAN;
  1152.   -186;
  1153. LIBCALL (base : ArpBasePtr) DateStamp*
  1154.   ( VAR date [1] : D.Date );
  1155.   -192;
  1156. LIBCALL (base : ArpBasePtr) Delay*
  1157.   ( timeout [1] : E.ULONG);
  1158.   -198;
  1159. LIBCALL (base : ArpBasePtr) WaitForChar*
  1160.   ( file    [1] : D.FileHandlePtr;
  1161.     timeout [2] : LONGINT)
  1162.   : BOOLEAN;
  1163.   -204;
  1164. LIBCALL (base : ArpBasePtr) ParentDir*
  1165.   ( lock [1] : D.FileLockPtr )
  1166.   : D.FileLockPtr;
  1167.   -210;
  1168. LIBCALL (base : ArpBasePtr) IsInteractive*
  1169.   ( file [1] : D.FileHandlePtr )
  1170.   : BOOLEAN;
  1171.   -216;
  1172. LIBCALL (base : ArpBasePtr) Execute*
  1173.   ( string [1] : ARRAY OF CHAR;
  1174.     file   [2] : D.FileHandlePtr;
  1175.     file2  [3] : D.FileHandlePtr )
  1176.   : LONGINT;
  1177.   -222;
  1178.  
  1179.  
  1180. (*
  1181.  ************************************************************************
  1182.  * Now for the stuff that only exists in arp.library...                 *
  1183.  ************************************************************************
  1184.  *)
  1185.  
  1186. (*
  1187. LIBCALL (base : ArpBasePtr) Printf *
  1188.   ( string [} : ARRAY OF CHAR;
  1189.     args   [] : ARRAY OF LONGINT )
  1190.   : LONGINT;
  1191.   -228;
  1192. LIBCALL (base : ArpBasePtr) FPrintf *
  1193.   ( file   [] : D.FileHandlePtr;
  1194.     string [] : ARRAY OF CHAR;
  1195.     args   [] : ARRAY OF LONGINT )
  1196.   : LONGINT;
  1197.   -234;
  1198. *)
  1199. LIBCALL (base : ArpBasePtr) Puts *
  1200.   ( string [9] : ARRAY OF CHAR )
  1201.   : LONGINT;
  1202.   -240;
  1203. LIBCALL (base : ArpBasePtr) ReadLine *
  1204.   ( VAR string [8] : ARRAY OF CHAR )
  1205.   : LONGINT;
  1206.   -246;
  1207. LIBCALL (base : ArpBasePtr) GADS *
  1208.   ( line      [8] : ARRAY OF CHAR;
  1209.     len       [0] : LONGINT;
  1210.     help      [9] : E.STRPTR;
  1211.     VAR args [10] : ARRAY OF SYS.LONGWORD;
  1212.     temp     [11] : ARRAY OF CHAR )
  1213.   : LONGINT;
  1214.   -252;
  1215. LIBCALL (base : ArpBasePtr) Atol *
  1216.   ( string [8] : ARRAY OF CHAR )
  1217.   : LONGINT;
  1218.   -258;
  1219. LIBCALL (base : ArpBasePtr) EscapeString *
  1220.   ( string [8] : ARRAY OF CHAR )
  1221.   : E.ULONG;
  1222.   -264;
  1223. LIBCALL (base : ArpBasePtr) CheckAbort *
  1224.   ( func [9] : E.PROC )
  1225.   : LONGINT;
  1226.   -270;
  1227. LIBCALL (base : ArpBasePtr) CheckBreak *
  1228.   ( mask [1] : SET;
  1229.     func [9] : E.PROC )
  1230.   : LONGINT;
  1231.   -276;
  1232. LIBCALL (base : ArpBasePtr) Getenv *
  1233.   ( string     [8] : ARRAY OF CHAR;
  1234.     VAR buffer [9] : ARRAY OF CHAR;
  1235.     size       [0] : LONGINT )
  1236.   : E.STRPTR;
  1237.   -282;
  1238. LIBCALL (base : ArpBasePtr) Setenv *
  1239.   ( varName [8] : ARRAY OF CHAR;
  1240.     value   [9] : ARRAY OF CHAR )
  1241.   : BOOLEAN;
  1242.   -288;
  1243. LIBCALL (base : ArpBasePtr) FileRequest *
  1244.   ( VAR fileRequester [8] : FileRequester )
  1245.   : E.STRPTR;
  1246.   -294;
  1247. LIBCALL (base : ArpBasePtr) CloseWindowSafely *
  1248.   ( window      [8] : I.WindowPtr;
  1249.     moreWindows [9] : I.WindowPtr );
  1250.   -300;
  1251. LIBCALL (base : ArpBasePtr) CreatePort *
  1252.   ( name [8] : ARRAY OF CHAR;
  1253.     pri  [0] : LONGINT )
  1254.   : E.MsgPortPtr;
  1255.   -306;
  1256. LIBCALL (base : ArpBasePtr) DeletePort *
  1257.   ( port [9] : E.MsgPortPtr );
  1258.   -312;
  1259. LIBCALL (base : ArpBasePtr) SendPacket *
  1260.   ( action  [0] : LONGINT;
  1261.     args    [8] : ArgArrayPtr;
  1262.     handler [9] : E.MsgPortPtr )
  1263.   : LONGINT;
  1264.   -318;
  1265. LIBCALL (base : ArpBasePtr) InitStdPacket *
  1266.   ( action     [0] : LONGINT;
  1267.     args       [8] : ArgArrayPtr;
  1268.     packet     [9] : D.DosPacketPtr;
  1269.     replyPort [10] : E.MsgPortPtr );
  1270.   -324;
  1271. LIBCALL (base : ArpBasePtr) PathName *
  1272.   ( lock           [0] : D.FileLockPtr;
  1273.     VAR buffer     [8] : ARRAY OF CHAR;
  1274.     componentCount [1] : LONGINT )
  1275.   : E.ULONG;
  1276.   -330;
  1277. LIBCALL (base : ArpBasePtr) Assign *
  1278.   ( logical  [8] : ARRAY OF CHAR;
  1279.     physical [9] : ARRAY OF CHAR )
  1280.   : E.ULONG;
  1281.   -336;
  1282. LIBCALL (base : ArpBasePtr) DosAllocMem *
  1283.   ( size [0] : LONGINT )
  1284.   : E.APTR;
  1285.   -342;
  1286. LIBCALL (base : ArpBasePtr) DosFreeMem *
  1287.   ( block [9] : E.APTR );
  1288.   -348;
  1289. LIBCALL (base : ArpBasePtr) BtoCStr *
  1290.   ( VAR cstr  [8] : ARRAY OF CHAR;
  1291.     bstr      [0] : D.BSTR;
  1292.     maxLength [1] : LONGINT )
  1293.   : E.ULONG;
  1294.   -354;
  1295. LIBCALL (base : ArpBasePtr) CtoBStr *
  1296.   ( cstr      [8] : ARRAY OF CHAR;
  1297.     VAR bstr  [0] : D.BSTR;
  1298.     maxLength [1] : LONGINT )
  1299.   : E.ULONG;
  1300.   -360;
  1301. LIBCALL (base : ArpBasePtr) GetDevInfo *
  1302.   ( devNode [10] : D.DeviceListPtr )
  1303.   : D.DeviceListPtr;
  1304.   -366;
  1305. LIBCALL (base : ArpBasePtr) FreeTaskResList * ()
  1306.   : BOOLEAN;
  1307.   -372;
  1308. LIBCALL (base : ArpBasePtr) ArpExit *
  1309.   ( rc    [0] : LONGINT;
  1310.     fault [2] : LONGINT );
  1311.   -378;
  1312. (*
  1313. LIBCALL (base : ArpBasePtr) ArpAlloc *
  1314.   ( size [] : LONGINT )
  1315.   : E.APTR;
  1316.   -384;
  1317. LIBCALL (base : ArpBasePtr) ArpAllocMem *
  1318.   ( size         [] : LONGINT;
  1319.     requirements [] : SET )
  1320.   : E.APTR;
  1321.   -390;
  1322. LIBCALL (base : ArpBasePtr) ArpOpen *
  1323.   ( name [] : ARRAY OF CHAR;
  1324.     mode [] : LONGINT )
  1325.   : D.FileHandlePtr;
  1326.   -396;
  1327. LIBCALL (base : ArpBasePtr) ArpDupLock *
  1328.   ( lock [] : D.FileLockPtr )
  1329.   : D.FileLockPtr;
  1330.   -402;
  1331. LIBCALL (base : ArpBasePtr) ArpLock *
  1332.   ( name [] : ARRAY OF CHAR;
  1333.     mode [] : LONGINT )
  1334.   : D.FileLockPtr;
  1335.   -408;
  1336. LIBCALL (base : ArpBasePtr) RListAlloc *
  1337.   ( VAR resList [] : ResList;
  1338.     size        [] : LONGINT )
  1339.   : E.APTR;
  1340.   -414;
  1341. *)
  1342. LIBCALL (base : ArpBasePtr) FindCLI *
  1343.   ( cliNum [0] : LONGINT )
  1344.   : E.APTR;
  1345.   -420;
  1346. LIBCALL (base : ArpBasePtr) QSort *
  1347.   ( data  [8] : E.APTR;
  1348.     rSize [0] : LONGINT;
  1349.     bSize [1] : LONGINT;
  1350.     comp  [9] : E.PROC )
  1351.   : BOOLEAN;
  1352.   -426;
  1353. LIBCALL (base : ArpBasePtr) PatternMatch *
  1354.   ( pattern [8] : ARRAY OF CHAR;
  1355.     string  [9] : ARRAY OF CHAR )
  1356.   : BOOLEAN;
  1357.   -432;
  1358. LIBCALL (base : ArpBasePtr) FindFirst *
  1359.   ( pattern  [0] : ARRAY OF CHAR;
  1360.     VAR path [8] : AnchorPath )
  1361.   : LONGINT;
  1362.   -438;
  1363. LIBCALL (base : ArpBasePtr) FindNext *
  1364.   ( VAR path [8] : AnchorPath )
  1365.   : LONGINT;
  1366.   -444;
  1367. LIBCALL (base : ArpBasePtr) FreeAnchorChain *
  1368.   ( VAR path [8] : AnchorPath );
  1369.   -450;
  1370. LIBCALL (base : ArpBasePtr) CompareLock *
  1371.   ( lock1 [0] : D.FileLockPtr;
  1372.     lock2 [1] : D.FileLockPtr )
  1373.   : E.ULONG;
  1374.   -456;
  1375. LIBCALL (base : ArpBasePtr) FindTaskResList * ()
  1376.   : ResListPtr;
  1377.   -462;
  1378. LIBCALL (base : ArpBasePtr) CreateTaskResList * ()
  1379.   : ResListPtr;
  1380.   -468;
  1381. LIBCALL (base : ArpBasePtr) FreeResList *
  1382.   ( freeList [9] : ResListPtr );
  1383.   -474;
  1384. LIBCALL (base : ArpBasePtr) FreeTrackedItem *
  1385.   ( item [9] : TrackerPtr );
  1386.   -480;
  1387. (*
  1388. LIBCALL (base : ArpBasePtr) GetTracker *
  1389.   ( size [] : LONGINT )
  1390.   : TrackerPtr;
  1391.   -486;
  1392. *)
  1393. LIBCALL (base : ArpBasePtr) GetAccess *
  1394.   ( tracker [9] : TrackerPtr )
  1395.   : E.APTR;
  1396.   -492;
  1397. LIBCALL (base : ArpBasePtr) FreeAccess *
  1398.   ( tracker [9] : TrackerPtr );
  1399.   -498;
  1400. LIBCALL (base : ArpBasePtr) FreeDAList *
  1401.   ( VAR node [9] : DirectoryEntry );
  1402.   -504;
  1403. LIBCALL (base : ArpBasePtr) AddDANode *
  1404.   ( data       [8] : ARRAY OF CHAR;
  1405.     VAR daList [9] : DirectoryEntry;
  1406.     length     [0] : LONGINT;
  1407.     id         [1] : LONGINT )
  1408.   : DirectoryEntryPtr;
  1409.   -510;
  1410. LIBCALL (base : ArpBasePtr) AddDADevs *
  1411.   ( VAR daList [8] : DirectoryEntry;
  1412.     select     [0] : SET )
  1413.   : E.ULONG;
  1414.   -516;
  1415. LIBCALL (base : ArpBasePtr) Strcmp *
  1416.   ( s1 [8] : ARRAY OF CHAR;
  1417.     s2 [9] : ARRAY OF CHAR )
  1418.   : LONGINT;
  1419.   -522;
  1420. LIBCALL (base : ArpBasePtr) Strncmp *
  1421.   ( s1     [8] : ARRAY OF CHAR;
  1422.     s2     [9] : ARRAY OF CHAR;
  1423.     length [0] : LONGINT )
  1424.   : LONGINT;
  1425.   -528;
  1426. (*
  1427. LIBCALL (base : ArpBasePtr) Toupper *
  1428.   ( char [] : LONGINT )
  1429.   : CHAR;
  1430.   -534;
  1431. *)
  1432. LIBCALL (base : ArpBasePtr) SyncRun *
  1433.   ( name    [8] : ARRAY OF CHAR;
  1434.     command [9] : E.STRPTR;
  1435.     input   [0] : D.FileHandlePtr;
  1436.     output  [1] : D.FileHandlePtr )
  1437.   : LONGINT;
  1438.   -540;
  1439.  
  1440. (*
  1441.  ************************************************************************
  1442.  *  Added V32 of arp.library                                            *
  1443.  ************************************************************************
  1444.  *)
  1445.  
  1446. LIBCALL (base : ArpBasePtr) ASyncRun *
  1447.   ( name     [8] : ARRAY OF CHAR;
  1448.     command  [9] : E.STRPTR;
  1449.     VAR pcb [10] : ProcessControlBlock )
  1450.   : LONGINT;
  1451.   -546;
  1452. LIBCALL (base : ArpBasePtr) SpawnShell *
  1453.   ( name       [8] : ARRAY OF CHAR;
  1454.     command    [9] : E.STRPTR;
  1455.     VAR shell [10] : NewShell )
  1456.   : LONGINT;
  1457.   -546;
  1458. LIBCALL (base : ArpBasePtr) LoadPrg *
  1459.   ( name [1] : ARRAY OF CHAR )
  1460.   : D.BPTR;
  1461.   -552;
  1462. LIBCALL (base : ArpBasePtr) PreParse *
  1463.   ( source   [8] : ARRAY OF CHAR;
  1464.     VAR dest [9] : ARRAY OF CHAR )
  1465.   : BOOLEAN;
  1466.   -558;
  1467.  
  1468. (*
  1469.  ************************************************************************
  1470.  * Added V33 of arp.library                                             *
  1471.  ************************************************************************
  1472.  *)
  1473.  
  1474. LIBCALL (base : ArpBasePtr) StamptoStr *
  1475.   ( VAR dateTime [8] : DateTime )
  1476.   : BOOLEAN;
  1477.   -564;
  1478. LIBCALL (base : ArpBasePtr) StrtoStamp *
  1479.   ( VAR dateTime [8] : DateTime )
  1480.   : BOOLEAN;
  1481.   -570;
  1482. LIBCALL (base : ArpBasePtr) ObtainResidentPrg *
  1483.   ( name [8] : ARRAY OF CHAR )
  1484.   : ResidentProgramNodePtr;
  1485.   -576;
  1486. LIBCALL (base : ArpBasePtr) AddResidentPrg *
  1487.   ( segment [1] : D.BPTR;
  1488.     name    [8] : ARRAY OF CHAR )
  1489.   : ResidentProgramNodePtr;
  1490.   -582;
  1491. LIBCALL (base : ArpBasePtr) RemResidentPrg *
  1492.   ( name [8] : ARRAY OF CHAR )
  1493.   : LONGINT;
  1494.   -588;
  1495. LIBCALL (base : ArpBasePtr) UnLoadPrg *
  1496.   ( segment [1] : D.BPTR );
  1497.   -594;
  1498. LIBCALL (base : ArpBasePtr) LMult *
  1499.   ( a [0] : LONGINT;
  1500.     b [1] : LONGINT )
  1501.   : LONGINT;
  1502.   -600;
  1503. LIBCALL (base : ArpBasePtr) LDiv *
  1504.   ( a [0] : LONGINT;
  1505.     b [1] : LONGINT )
  1506.   : LONGINT;
  1507.   -606;
  1508. LIBCALL (base : ArpBasePtr) LMod *
  1509.   ( a [0] : LONGINT;
  1510.     b [1] : LONGINT )
  1511.   : LONGINT;
  1512.   -612;
  1513. LIBCALL (base : ArpBasePtr) CheckSumPrg *
  1514.   ( VAR node [0] : ResidentProgramNode )
  1515.   : E.ULONG;
  1516.   -618;
  1517. LIBCALL (base : ArpBasePtr) TackOn *
  1518.   ( VAR pathname [8] : ARRAY OF CHAR;
  1519.     filename     [9] : ARRAY OF CHAR );
  1520.   -624;
  1521. LIBCALL (base : ArpBasePtr) BaseName *
  1522.   ( name [8] : ARRAY OF CHAR )
  1523.   : E.STRPTR;
  1524.   -630;
  1525. LIBCALL (base : ArpBasePtr) ReleaseResidentPrg *
  1526.   ( segment [1] : D.BPTR )
  1527.   : ResidentProgramNodePtr;
  1528.   -636;
  1529.  
  1530. (*
  1531.  ************************************************************************
  1532.  * Added V36 of arp.library                                             *
  1533.  ************************************************************************
  1534.  *)
  1535.  
  1536. (*
  1537. LIBCALL (base : ArpBasePtr) SPrintf *
  1538.   ( VAR buffer [] : ARRAY OF CHAR;
  1539.     string     [] : ARRAY OF CHAR;
  1540.     stream     [] : ARRAY OF LONGINT )
  1541.   : LONGINT;
  1542.   -642;
  1543. LIBCALL (base : ArpBasePtr) GetKeywordIndex *
  1544.   ( key      [] : ARRAY OF CHAR;
  1545.     template [] : ARRAY OF CHAR )
  1546.   : LONGINT;
  1547.   -648;
  1548. LIBCALL (base : ArpBasePtr) ArpOpenLibrary *
  1549.   ( name    [] : ARRAY OF CHAR;
  1550.     version [] : LONGINT )
  1551.   : E.LibraryPtr;
  1552.   -654;
  1553. LIBCALL (base : ArpBasePtr) ArpAllocFreq * ()
  1554.   : FileRequesterPtr;
  1555.   -660;
  1556. *)
  1557.  
  1558.  
  1559. (* --- C Macros defined as procedures ----------------------------------- *)
  1560. (* $L+ Absolute long addressing for globals *)
  1561.  
  1562.  
  1563. (* --- Library Base variable -------------------------------------------- *)
  1564. (* $L- Address globals through A4 *)
  1565.  
  1566.  
  1567. (*------------------------------------*)
  1568. PROCEDURE* CloseLib ();
  1569.  
  1570. BEGIN (* CloseLib *)
  1571.   IF base # NIL THEN E.base.CloseLibrary (base) END
  1572. END CloseLib;
  1573.  
  1574. (*------------------------------------*)
  1575. PROCEDURE OpenLib * (mustOpen : BOOLEAN);
  1576.  
  1577. BEGIN (* OpenLib *)
  1578.   IF base = NIL THEN
  1579.     base :=
  1580.       SYS.VAL
  1581.         ( ArpBasePtr,
  1582.           E.base.OpenLibrary (name, version) );
  1583.     IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
  1584.     ELSIF mustOpen THEN HALT (100)
  1585.     END;
  1586.   END
  1587. END OpenLib;
  1588.  
  1589. BEGIN (* ARP *)
  1590.   base := NIL
  1591. END ARP.
  1592.